package com.day19.ex10;

import java.io.*;

public class ObjectStreamDemo {
    public static void main(String[] args) throws IOException,ClassNotFoundException {
        read();
    }
    private static void read() throws IOException,ClassNotFoundException{
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("myOtherStream\\oos.txt"));
        Object obj=ois.readObject();
        Student s=(Student)obj;
        System.out.println(s.getName()+","+s.getAge());
        ois.close();
    }
    private static void write() throws IOException{
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("myOtherStream\\oos.txt"));
        Student s=new Student("林青霞",30);
        oos.writeObject(s);
        oos.close();
    }
}
